package br.usp.ime.lab.coverage.mcdc;

import org.nfunk.jep.JEP;
import org.nfunk.jep.Node;

public class EvaluationExpression {

	private String expression;  
    private JEP jep;  
      
    public EvaluationExpression(String expr) {  
	    this.expression = expr;  
	    jep = new JEP();  
    }  
    
    public JEP getJep() {  
    	return jep;  
    }
    
    public boolean evaluate() {  
	    try {  
		    Node n1 = jep.parse(expression);  
		    Double result = (Double) jep.evaluate(n1);  
	    	return (!result.equals(0.0d));  
	    } catch (Exception e) {  
	    	System.out.println("An error occured: " + e.getMessage());  
	    }  
	    return false;  
    }
}
